package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseTreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

/**
 * 部门表的实体类
 *
 * 下拉多写: 滚珠下拉
 * 格式化: ctrl + alt + l
 * 光标的前后移动: Home End
 */
@Data  //自动生成get set 和 toString方法
@AllArgsConstructor  //有参构造
@NoArgsConstructor   //无参构造
@Table(name = "t_department")  //表名
@ApiModel(value = "部门对象",description = "部门对象参数")
public class Department extends BaseTreeNode<Department> {

    //部门编号
    @ApiModelProperty(value = "部门编号")
    @Size(min = 3,max = 8,message = "部门编号必须在3-8位之间")
    private String sn;

    //部门名称
    @ApiModelProperty(value = "部门名称")
    @NotBlank(message = "部门名称不能为空")
    private String name;

    //部门状态 1:正常 0:禁用
    private Integer state;

    //部门经理id
    @Column(name = "manager_id")
    private Long managerId;

    //上级部门id
    @Column(name = "parent_id")
    private Long parentId;

    //
    @Column(name = "dir_path")
    private String dirPath;

    //@Transient 临时字段,配置这段注解,这个字段就不参与表的crud了
    @Transient
    private Employee manager;

    @Transient
    private Department parent;

    @Transient
    private Long[] parentIds;
}
